//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System.ComponentModel;
using System.Workflow.ComponentModel;
using Microsoft.Research.ScientificWorkflow;

namespace TridentBasicActivities.Activities
{
    [Name("Activity for performing and operation between two bools", "Condition AND", "AND")]
    [Description("Performs AND between the two Inputs.")]
    [WorkflowCategory("Condition")]
    public class CondAND : CondBase
    {
        public static System.Workflow.ComponentModel.DependencyProperty Input1Property =
            System.Workflow.ComponentModel.DependencyProperty.Register("Input1", typeof(bool),
            typeof(CondAND));

        [RequiredInputParam]
        [Name("Input1")]
        [Description("First boolean value for doing the AND operation.")]
        public bool Input1
        {
            get { return (bool)GetValue(CondAND.Input1Property); }
            set { SetValue(CondAND.Input1Property, value); }
        }

        public static System.Workflow.ComponentModel.DependencyProperty Input2Property =
            System.Workflow.ComponentModel.DependencyProperty.Register("Input2", typeof(bool),
            typeof(CondAND));

        [RequiredInputParam]
        [Name("Input2")]
        [Description("Second boolean value for doing the AND operation.")]
        public bool Input2
        {
            get { return (bool)GetValue(CondAND.Input2Property); }
            set { SetValue(CondAND.Input2Property, value); }
        }


        public static System.Workflow.ComponentModel.DependencyProperty ResultProperty =
            System.Workflow.ComponentModel.DependencyProperty.Register("Result", typeof(bool),
            typeof(CondAND));

        [OutputParam]
        [Name("Result")]
        [Description("Result of the AND operation.")]
        public bool Result
        {
            get { return (bool)GetValue(CondAND.ResultProperty); }
            set { SetValue(CondAND.ResultProperty, value); }
        }


        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            this.Result = Input1 && Input2;
            return ActivityExecutionStatus.Closed;
        }
    }
}
